package com.shoujifeng.snowmusic.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import com.geniuseoe2012.lazyloaderdemo.cache.OnlineGalleryImageLoader;
import com.shoujifeng.snowmusic.player.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class GalleryAdapter extends BaseAdapter {
	Context mContext;
	//int[] res = new int[] { R.drawable.gallery1, R.drawable.gallery2, R.drawable.gallery3};
	ArrayList<HashMap<String, Object>> list;
	OnlineGalleryImageLoader imageLoader;
	public GalleryAdapter(Context cnt,ArrayList<HashMap<String, Object>> list) {
		this.mContext = cnt;
		this.list=list;
		imageLoader = new OnlineGalleryImageLoader(mContext);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
		
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		if (arg1 == null) {
			arg1 = LayoutInflater.from(mContext).inflate(R.layout.gallery_item,
					null);
		}
		ImageView img = (ImageView) arg1.findViewById(R.id.home_img);
		//img.setBackgroundResource(res[arg0]);
		imageLoader.DisplayImage(list.get(arg0).get("icon_url").toString(),img, false,R.drawable.gallery3);
		return arg1;
	}
}
